window.onload=function () {

    //第一题
    var date = new Date();
    var str="今天是"+date.getFullYear()+"年"+(date.getMonth()+1)+"月"+date.getDay()+"日"
    document.getElementById("firstDiv").innerText=str;

    //第三题
    document.onmousemove=function (e) {
        var str = e.clientX+","+e.clientY;
        document.getElementById("thirdInput").value=str
    }


}

//第二题
function second() {
    //获取输入的字符串
    var str=document.getElementById("secondInput").value;
    if(str){
        //转成数组
        var arr = str.split("")
        //利用数组的方法翻转，再结合成字符串 join方法里的参数为间隔符号，默认逗号，此处改为空字符串
        str = arr.reverse().join("");
        //转成大写
        str = str.toUpperCase();
    }
    document.getElementById("secondSpan").innerText = str;
}

//第四题
function fourth(type) {
    if(type ==1){
        document.getElementById("fourthDiv").style="background-color:red";
    }else if(type ==2){
        document.getElementById("fourthDiv").style="background-color:blue";
    }else if(type ==3){
        document.getElementById("fourthDiv").style="background-color:green";
    }
}
//第五题
function fifth() {
    var name= document.getElementById("fifthName").value;
    var age= document.getElementById("fifthAge").value;
    var occ= document.getElementById("fifthOccupation").value;
   if(check(name,age)) {
        console.log( "姓名："+name+"；年龄："+name+"；职业："+name)
   }
}

function check(name,age) {
    if(!name){
        console.log( "姓名为空，请输入");
        return false;
    }
    if(!(age>16 && age<40)){
        console.log( "年龄不符合要求");提交
        return false;
    }
    return true;
}

//第七题
function compute(type) {
    var one = parseInt(document.getElementById("numberOne").value);
    var two = parseInt(document.getElementById("numberTwo").value);
    if(type ==1){
        document.getElementById("numberResult").value=one+two;
    }else if(type ==2) {
        document.getElementById("numberResult").value=one-two;

    }else if(type ==3) {
        document.getElementById("numberResult").value=one*two;

    }else if(type ==4) {
        document.getElementById("numberResult").value=one/two;
    }

}